
Tida.ready({
    // interactId:"", // 互动实列ID type string 若无抽奖模块，此参数无须传入。给错误的实例ID会走错误流程
    // module: [] // 应用所需要的模块。非必选，默认加载所有模块。支持的模块见注释。
    // sellerNick:"" // 商家名称 
    // shopId:123 // 店铺ID 从url中取 可选
	module : ["device", "media", "server", "social", "widget", "sensor", "share","buy","draw","im","calendar","prize"],
    // debug : 1,
    // combo: 0,
	// console:1,
    interactId : Tida.getParam("interactId")||"c27335b4-c510-4183-a8e6-19ad57a1dc8a"//"c69bb4a4-dc94-4076-9aec-1baeb47b70b4"//"8ecc923e-0d5c-4f65-ae55-49dc22d2d8f1"//"462b2fd6-84fb-4d55-b451-bde8e19fc475"//"b9cc10a9-916d-4481-b840-e6ad3ceaddf0"//"f9d8c5d0-c894-47a7-a7e8-3eb9541f0e07"//"6a46ff4d-9423-4a39-8d5a-db6b6c961439"//"456de863-cda2-495f-acab-495b4aece2cc"//"a8e9c835-09db-45dd-bbc1-8964baa337d6"//"e5616f6f-9a8b-460c-abaa-25b787841948"
    //module:["draw","prize","buy","device","media","social","widget","im","server","share","award"]
}, function(){
	var mixednick;
	var codeimg;
	var short_url;
	// var friendnick = $(".friend").val();
	// var cid = $(".cid").val();
	// var sid = $(".sid").val();
    // TODO
	Tida.doAuth(function(data){
		if(data.finish){
			// 授权成功 可以顺利调用需要授权的接口了

		Tida.mixNick({},function(data){
			if(data.success){
				// $(".mixednick").val(data.mixnick);
				mixednick = data.mixnick;
			}
		});
		}else {
			// 未能成功授权
		}
	});
	
	var watchId = Tida.shake.watch({
		frequency: 25, // 采样间隔(毫秒) 
	}, function (data) {
		if (data.errorCode) {
			console.error(data.errorCode, data.errorMessage);
		} else {
			$.getJSON("/?m=shakemobile&t=1234234234&a=shake",function(json){
				if(!json.status){
					alert(json.giftname);
				}else{
					$('.red-ss').addClass('wobble');
					$(".giftname").html("<a>"+json.giftname+"</a>");
					$(".red-tc-btn button").html("<a>"+json.withdraw+"</a>");
					setTimeout(function(){
						// audio.pause();
						// openAudio.play();
						$('.red-tc').css('display', 'block');
					}, 1500);
				}
			});
			// errorCode为0 摇一摇成功触发
			// alert('Shaked!');
		}
	});

});

	

// $(document).ready(function() {
	// if (window.DeviceMotionEvent){
		// var speed = 25;
		// var audio = document.getElementById("shakemusic");
		// var openAudio = document.getElementById("openmusic");
		// var x = t = z = lastX = lastY = lastZ = 0;
		// window.addEventListener('devicemotion',
			// function () {
				// var acceleration = event.accelerationIncludingGravity;
				// x = acceleration.x;
				// y = acceleration.y;
				// if (Math.abs(x - lastX) > speed || Math.abs(y - lastY) > speed) {
					// audio.play();
					// $('.red-ss').addClass('wobble')
					// setTimeout(function(){
						// audio.pause();
						// openAudio.play();
						// $('.red-tc').css('display', 'block');
					// }, 1500);
				// };
				// lastX = x;
				// lastY = y;
			// },false);
	// };
	// $()
// });





